package com.hhh.Util;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
//为加了@TableField的Employee属性添加元数据
public class GetSessionId implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("createUser", GetThreadNow.GetIdInSession());
        metaObject.setValue("updateUser", GetThreadNow.GetIdInSession());
        //GetThreadNow.CloseThread();
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("updateUser", GetThreadNow.GetIdInSession());
        //GetThreadNow.CloseThread();
    }
}
